﻿using System.Collections.Generic;
using UnityEngine;

namespace LightGameLibs
{
    [System.Serializable]
    public class CombinableRTA : RichTextArg
    {
        public RichTextArg m_before;
        public RichTextArg m_after;
        public List<RichTextArg> m_filled = new List<RichTextArg>();

        public string GetCombinableRichText(Color defaultColor, int defaultSize, FontStyle defaultType)
        {
            var result = m_before.GetRichText(defaultColor, defaultSize, defaultType);

            var filled = new List<string>();
            for (int i = 0, length = m_filled.Count; i < length; i++)
            {
                filled.Add(m_filled[i].GetRichText(defaultColor, defaultSize, defaultType));
            }

            result = result.Add(StringUtility.Format(GetRichText(defaultColor, defaultSize, defaultType), filled.ToArray()));

            if (null != m_after)
            {
                result = result.Add(m_after.GetRichText(defaultColor, defaultSize, defaultType));
            }

            return result;
        }
    }
}